﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace PFMHandlers
{
   public class PFMDecodeHandler
    {
       public byte[] PFMDecode(byte[] Decode)
       {
           PFMGlobals.PFMDefinitions.param = new CspParameters();
           PFMGlobals.PFMDefinitions.param.KeyContainerName = "Olive";
           using (RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(PFMGlobals.PFMDefinitions.param))
           {
               //byte[] encryptdata = Convert.FromBase64String(this.txtjiami.Text);
               return rsa.Decrypt(Decode, false);
               //txthjiemi.Text = Encoding.Default.GetString(decryptdata);
           }
           //Decode = PFMGlobals.PFMDefinitions.buffer;
           //MemoryStream ms = new MemoryStream(Decode);//将加密后的字节数据加入内存流中
           //CryptoStream cryStream = new CryptoStream(ms, PFMGlobals.PFMDefinitions.DesCSP.CreateDecryptor(), CryptoStreamMode.Read);//内存流连接到解密流中
           //StreamReader sr = new StreamReader(cryStream);
           //string b = sr.ReadLine();
           //byte []a= Encoding.Default.GetBytes(b);//将解密流读取为字符串
           //sr.Close();
           //cryStream.Close();
           //ms.Close();
           //return a;
       }
    }
}
